package com.petlab.service.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Component;

import com.petlab.common.FilePath;
import com.petlab.forum.source.ReadInformationFromXMLFile;
import com.petlab.model.Article;
import com.petlab.service.ArticleInformation;

@Component("articleInformation")
public class ArticleInformationImpl implements ArticleInformation {
	public HashMap<String, List<?>> getArticleInformation(Article article,int articlePage) {
		// TODO Auto-generated method stub
		String themeTitle = article.getThemeTitle();
		int articleId = article.getArticleId();

		String filename = FilePath
				.getParentDirectory(FilePath.getParentDirectory(this.getClass()
						.getResource("/").getFile()))
				+ "forum/" + themeTitle + "/" + articleId + ".xml";
		
		return ReadInformationFromXMLFile.getInformation(filename,articlePage);	

	}
	public int getSize(Article article) {
		// TODO Auto-generated method stub
		String themeTitle = article.getThemeTitle();
		int articleId = article.getArticleId();

		String filename = FilePath
				.getParentDirectory(FilePath.getParentDirectory(this.getClass()
						.getResource("/").getFile()))
				+ "forum/" + themeTitle + "/" + articleId + ".xml";
		
		return ReadInformationFromXMLFile.getSize(filename);
	}
}
